<?php 

class IndexAction extends BaseAction{


	/**
	 * 首页
	 * @return [type] [description]
	 */
	function index(){
		//echo U('news/index');
		//header('Location:'.U('news/index'));
		//exit();
		$map['cid'] = 1;
		$banners = M('ad')->where($map)->select();
		$map2['path'] = array('like','0,189,%');
		$map2['flag'] = array('like','%h%');
		$solution = M("content")->where($map2)->order(array("orderid"=>"asc","id"=>"desc"))->limit(7)->select();
		//$solution['style']=explode(';',$solution['style']);
	//	echo M("content")->getlastsql();
		$map3['path'] = array('like','0,53,%');
		$map3['flag'] = array('like','%h%');
		$product = M("content")->where($map3)->order(array("orderid"=>"asc","id"=>"desc"))->limit(7)->select();
		$map4['path'] = array('like','0,55,%');
		$map4['flag'] = array('like','%h%');
		$news = M("content")->where($map4)->order(array("orderid"=>"asc","posttime"=>"desc","id"=>"desc"))->limit(2)->select();
		
		$ad1 = M('ad')->where(array("id"=>5))->find();
		$ad2 = M('ad')->where(array("id"=>6))->find();
		$indexabout = M('content')->where(array("id"=>403))->find();
		$indexvideo = M('content')->where(array("id"=>411))->find();
		$data = json_decode($indexvideo['content_arr'], true);
		$indexvideo['video'] = $data['video'];
		//var_dump($data);
		//echo $indexvideo['video'];
		//$indexvideo['video']='1';
		$this->assign("banners",$banners);
		$this->assign("solution",$solution);
		$this->assign("product",$product);
		$this->assign("news",$news);
		$this->assign("ad1",$ad1);
		$this->assign("ad2",$ad2);
		$this->assign("indexabout",$indexabout);
		$this->assign("indexvideo",$indexvideo);
		$this->assign("menucss1","on");
		$this->display();
		//header("location:".U("cn"));
	}


	/**
	 * 简介
	 * @return [type] [description]
	 */
	function catalog(){
		$map['pid'] = 53;   //news
		$id = I('id');
		if($id){
			$maps['pid'] = $id;
		}else{
			$maps['path'] = array('like','0,53%');
		}
		$count  = M('content')->where($maps)->count();// 查询满足要求的总记录数
		import('ORG.Util.Page');// 导入分页类
		$Page   = new Page($count,8);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show   = $Page->show();// 分页显示输出
		$list = M("content")->order(array("orderid"=>"asc"))->where($maps)->limit($Page->firstRow.','.$Page->listRows)->select();
		$cate = M("category")->where($map)->select();
		$this->assign("list",$list);
		$this->assign("cate",$cate);
		$this->assign('page',$show);// 赋值分页输出
		$this->display();
	}

	function products(){
		$map1['pid'] = 57;   //Ceramics
		$map2['pid'] = 58;   //Sanitary ware
		$list1 = M("category")->order(array("orderid"=>"asc"))->where($map1)->select();
		$list2 = M("category")->order(array("orderid"=>"asc"))->where($map2)->select();
		$this->assign("list1",$list1);
		$this->assign("list2",$list2);
		$this->display();
	}

	function store(){		
		$map['pid'] = 189;   //news
		$id = I('cid');
		if($id){
			$maps['pid'] = $id;
		}else{
			$maps['path'] = array('like','0,189%');
		}
		echo $count  = M('content')->where($maps)->count();// 查询满足要求的总记录数
		import('ORG.Util.Page');// 导入分页类
		$Page   = new Page($count,8);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show   = $Page->show();// 分页显示输出
		$list = M("content")->order(array("orderid"=>"asc"))->where($maps)->limit($Page->firstRow.','.$Page->listRows)->select();
		$cate = M("category")->where($map)->select();
		$this->assign("list",$list);
		$this->assign("cate",$cate);
		$this->assign('page',$show);// 赋值分页输出
		$this->display();
	}

	function merchant(){		
		$this->display();
	}


	function search(){
		$keyword = I('k');
		$map['title'] = array('like',"%$keyword%");
		$map["path"] = array('like',"0,54%");
		$map["id"] = array("gt","60");
		import('ORG.Util.Page');// 导入分页类
		$count = M("content")->order(array("orderid"=>"asc"))->where($map)->count();
		$Page   = new Page($count,6);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show   = $Page->show();// 分页显示输出
		$list = M("content")->order(array("orderid"=>"asc"))->where($map)->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign("list",$list);
		$this->assign('page',$show);
		$this->display();
	}

	function content(){
		$id = I('id');
		$map['id'] = $id;
		$list = M("category")->where($map)->find();
		$this->assign("r",$list);
		$this->display();
	}

}

?>